<?php
namespace Home\Controller;

use Think\Controller;
use Org\Util\Rbac;

class CommonController extends Controller
{
    // 判断是否登录
    public function _initialize()
    {
        if (!isset($_SESSION[C('USER_AUTH_KEY')])) {
            $this->redirect('Home/Index/index');
        }
        $notAuth = in_array(MODULE_NAME, explode(',', C('NOT_AUTH_MODULE'))) || in_array(ACTION_NAME, C('NOT_AUTH_ACTION'));
        if (C("USER_AUTH_ON") && !$notAuth) {// 判断权限
            Rbac::AccessDecision() || $this->error("无法访问");
        }
    }

}
